#include "ScnsNrf24l01.c.h"

#if defined(SCNS_NRF24L01_ENABLE)&&SCNS_NRF24L01_ENABLE==1

#include "ScnsTimer.h"
#include "ScnsSmctp.h"
#include "spi.h"

const ScnsBspNrf24l01Config scnsBspNrf24l01Config[SCNS_NRF24L01_MAX]={
    {
        .rxAddr={0X12,0X18,0XFF,0XFF,0XFF},
        .freq=2523,
    }
};

void scnsBspNrf24l01RW(ScnsNrf24l01Enum nrfN,uint8*val,uint32 num)
{
    HAL_SPI_TransmitReceive(&hspi2,val,val,num,500);
}

uint8 scnsBspNrf24l01GetIrq(ScnsNrf24l01Enum nrfN)
{
    return (NRF_IRQ_GPIO_Port->IDR&NRF_IRQ_Pin)?1:0;
}

void scnsBspNrf24l01SetCe(ScnsNrf24l01Enum nrfN,uint8 dat)
{
    NRF_CE_GPIO_Port->BSRR=(dat)?(NRF_CE_Pin):(NRF_CE_Pin<<16);
}

void scnsBspNrf24l01SetCs(ScnsNrf24l01Enum nrfN,uint8 dat)
{
    NRF_CS_GPIO_Port->BSRR=(dat)?(NRF_CS_Pin):(NRF_CS_Pin<<16);
}

void scnsBspNrf24l01ReceiveCallback(ScnsNrf24l01Enum nrfN,uint8 data[],uint8 len)
{
    scnsNrf24l01Send(nrfN,data,len);
    hxPrintfFL("%#04&*hhX",len,data);
}

#endif
